package com.bizmerce.rnd.oms.decision.criterion;

import java.util.List;

import com.bizmerce.rnd.oms.decision.data.BillOfMaterials;
import com.bizmerce.rnd.oms.decision.data.RawMaterial;

/**
 * 대상협정: 한-미 FTA
 * 순원가법: Net Cost Method
 * @param nc Net cost, 총비용(제조원가 + 판매비 + 일반관리비) - 
 *        공제비용(판촉, 마케팅, 판매 후 서비스, 로열티, 운송/포장 및 허용범위를 벗어난 이자비용)
 * @param vnm Value of Non-originating Material
 */
public class NetCostMethod extends LocalContents {
	//return Math.floor((nc - vnm) / nc * 100);
	public Boolean assign(BillOfMaterials bom) {
		double ncValue = bom.getSalePrice();
		double vnmValue = 0.;
		List<RawMaterial> materials = bom.getRawMaterials();
		for (RawMaterial rawMaterial : materials) {
			if(rawMaterial.isNotIntraItem()) {
				vnmValue +=  rawMaterial.getPurchasePrice();
			}
		}	
		boolean result = false;
		double value = Math.floor((ncValue - vnmValue) / ncValue * 100);
		System.out.println("NC:" + value + "%");
		result = (value >= 45); //45%
		return result;
	}
}
